//
//  DHUserAddressCell.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/6/25.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "DHUserAddressCell.h"
#import "Address.h"
#import "DHContactViewController.h"

@interface DHUserAddressCell()

@property (strong, nonatomic) NSDictionary *address;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelWidthLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *nameWidthLayout;

@end

@implementation DHUserAddressCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.labelLabel.layer.borderWidth = 1;
    self.labelLabel.layer.borderColor = [[UIColor colorWithHexString:@"#E03E3E"] CGColor];
    self.labelLabel.layer.cornerRadius = 3;
}

- (IBAction)editAction:(id)sender {
//    Address *address = [[Address alloc] init];
//    address.label = [self.address objectForKey:@"label"];
//    address.accurate = [self.address objectForKey:@"accurate"];
//    address.address = [self.address objectForKey:@"address"];
//    address.city = [self.address objectForKey:@"city"];
//    address.phone = [self.address objectForKey:@"phone"];
//    address.district = [self.address objectForKey:@"district"];
//    address.province = [self.address objectForKey:@"province"];
//    address.name = [self.address objectForKey:@"contact"];
//
//    self.address_id = [dic objectForKey:@"_id"];
//    DHContactViewController *vc = [[DHContactViewController alloc] init];
//    vc.isManager = YES;
//    vc.address = address;
//    [self.navigationController pushViewController:vc animated:YES];
}

- (void)updateCell:(NSDictionary *)dic{
    self.address = dic;
    self.labelLabel.text = [dic objectForKey:@"label"];
    self.addressLabel.text = [NSString stringWithFormat:@"%@",[dic objectForKey:@"address"]];
    self.nameLabel.text = [dic objectForKey:@"contact"];
    self.phoneLabel.text = [dic objectForKey:@"phone"];
    
    self.labelWidthLayout.constant = [self.labelLabel.text widthForFont:self.labelLabel.font] + 3;
    self.nameWidthLayout.constant = [self.nameLabel.text widthForFont:self.nameLabel.font] + 8;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
